package codetop.kuaishou.T137;

/**
 * @Author: 18362
 * @Create: 2022-09-16 1:54:04 星期五
 */
class Solution {
    public int singleNumber(int[] nums) {
        int[] cnt = new int[32];
        for (int num : nums) {
            for (int i = 0; i < cnt.length; i++) {
                int mask = 1 << i;
                if ((num & mask) != 0)
                    cnt[i]++;
                cnt[i] = cnt[i] % 3;
            }
        }
        int res = 0;
        for (int i = 0; i < cnt.length; i++) {
            if (cnt[i] > 0)
                res += (1 << i);
        }
        return res;
    }
}